<div id="tiga_ba">
	<div id="tiga_baa">Data Desa </div>
	<div id="tiga_bab">
		<a href="javascript:void(0)" onClick="location.href='utama.php?module=mod_desa&view=form_tambah'">
			<button class="button">Tambah</button>
		</a>
	</div>
	<div class="clear"></div>
</div>

<?php
	if(!empty($_GET['nama'])){
		$param_nama=$_GET['nama'];
		$jenis=$_GET['jenis'];
	}else{
		$param_nama=$_POST['nama'];
		$jenis=$_POST['jenis_cari'];
	}

	if(empty($jenis)){
		$jenis="desa";
		$sd = "selected";
	}else if($jenis=='kecamatan'){
		$sk = "selected";
	}else if($jenis=='kabupaten'){
		$skb = "selected";
	}else if($jenis=='propinsi'){
		$sp = "selected";
	}
?>
<form method=post action='utama.php?module=mod_desa'>
	<table style="margin-left: 5px;" width="830" >
		<tr>
			<td width="65">Pencarian  : </td>
			<td width="200">
				<select name="jenis_cari" class="input_field">
					<option value="desa" <?php echo $sd; ?>>Desa</option>
					<option value="kecamatan" <?php echo $sk; ?>>Kecamatan</option>
					<option value="kabupaten" <?php echo $skb; ?>>Kabupaten</option>
					<option value="propinsi" <?php echo $sp; ?>>Provinsi</option>
				</select>
			</td>
			<td width="200"><input type="text" name="nama" value="<?php echo $param_nama; ?>" class="input_field" /></td>
			<td><input name="submit" type="submit" class="button" value="Cari" /></td>
			<td></td>
			<td align="right"><a href="utama.php?module=mod_desa&view=form_cetak"><img src="asset/images/print.png" width="30"></a></td>
		</tr>
	</table>
</form>

<table class="tabel">
	<tr>
		<th>NO</th>
		<th>Aksi</th>
		<th>Kode Desa</th>
		<th>Desa</th>
		<th>Kecamatan</th>
		<th>Kabupaten</th>
		<th>Provinsi</th>
	</tr>
	<?php
		$p= new paging ;
		$batas= 10;

		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		$sql="select id_desa, desa, kecamatan, kabupaten, propinsi from desa d inner join kecamatan c on d.id_kecamatan = c.id_kecamatan inner join kabupaten k on c.id_kabupaten = k.id_kabupaten inner join propinsi p on k.id_propinsi = p.id_propinsi where $jenis like '%$param_nama%' and k.aktif = 'Y' and p.aktif = 'Y' order by id_desa limit $posisi,$batas";
		//echo $sql;
		$qry=mysql_query($sql);
		$no=$posisi + 1;
		if(mysql_num_rows($qry)>0){
		
			while($hasil=mysql_fetch_array($qry)){
	?>
				<tr>
					<td align="center" width="30"><?php echo $no;?></td>
					<td align="center" width="60">
						<a href="utama.php?module=mod_desa&view=form_edit&id=<?php echo $hasil['id_desa'];?>">
						<img src="asset/images/edit.png" title="Ubah Data"></a> 
						<?php hapus_data("$hasil[id_desa]","id_desa","id_desa","desa","keluarga","Desa","mod_desa") ?>
					</td>
					<td align="center" width="60"><?php echo $hasil['id_desa'];?></td>
					<td ><?php echo $hasil['desa'];?></td>
					<td ><?php echo $hasil['kecamatan'];?></td>
					<td ><?php echo $hasil['kabupaten'];?></td>
					<td ><?php echo $hasil['propinsi'];?></td>
				</tr>
				
		<?php
				$no++;
			}
		}else{
		?>
	
	<tr>
		<td colspan="7" align="center">Data tidak Ada </td>
	</tr>
	
	<?php
		}
	?>
</table>

<?php
	$sql2="select id_desa, desa, kecamatan, kabupaten, propinsi from desa d inner join kecamatan c on d.id_kecamatan = c.id_kecamatan inner join kabupaten k on c.id_kabupaten = k.id_kabupaten inner join propinsi p on k.id_propinsi = p.id_propinsi where $jenis like '%$param_nama%' and k.aktif = 'Y' and p.aktif = 'Y'" ;
	$query2=mysql_query($sql2);
	$jumlah_data=mysql_num_rows($query2);
	//dapatkan jumlah halaman
	$jumlah_halaman= $p->jumlahhalaman($jumlah_data,$batas);
	//cetak link
	$linkhalaman=$p->navhalaman($_GET['halaman'],$jumlah_halaman,$_SERVER['PHP_SELF']."?module=mod_desa&jenis=$jenis","nama=$param_nama");
	print($linkhalaman);
?>
        